﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using RemotingMessage;

namespace Utilities
{
    public static class MachineSettings
    {
        private static Dictionary<int, string> DeviceControlButtons = new Dictionary<int, string>();
        static MachineSettings()
        {
            string room;
            for (int i = 1; i <= RoomCount; i++)
            {
                room = "Button_" + i.ToString();
                DeviceControlButtons.Add(i, ConfigurationManager.AppSettings.Get(room));
            }
        }

        public static int RoomCount { get { return int.Parse(ConfigurationManager.AppSettings.Get("RoomCount")); } }

        //TODO: Must be deleted!
        //public static string ConferenceRoom1
        //{
        //    get { return ConfigurationManager.AppSettings.Get("ConferenceRoom1"); }
        //}

        //public static string ConferenceRoom2
        //{
        //    get { return ConfigurationManager.AppSettings.Get("ConferenceRoom2"); }
        //}

        //public static string ConferenceRoom3
        //{
        //    get { return ConfigurationManager.AppSettings.Get("ConferenceRoom3"); }
        //}

        //public static string ConferenceRoom4
        //{
        //    get { return ConfigurationManager.AppSettings.Get("ConferenceRoom4"); }
        //}

        public static string ButtonNumberToRoom(int ButtonNumber) 
        {
            if (!DeviceControlButtons.Where(p => p.Key == ButtonNumber).Any()) return "";
            return DeviceControlButtons.Where(p => p.Key == ButtonNumber).Single().Value;
        }

        public static int RoomToButtonNumber(string room)
        {
            if (!DeviceControlButtons.Where(p => p.Value == room).Any()) return -1;
            return DeviceControlButtons.Where(p => p.Value == room).Single().Key;
        }
    }
}
